﻿@using Ids.Web.Listing
@using System.Collections
@using System.Collections.Generic
@using Novagoal.Website.WebApp.Helpers
@using System.Text
@using Novagoal.Website.Models

@model SubmitResults

@{
    MvcHtmlString HtmlErrorsDisplay = null;
    var model = ViewData.Model as ModelErrors;
    if (model != null && model.HasErrors())
    {
        if (model.Errors.Count == 1)
        {
            string strError = string.Format("<b>{0}</b>", model.Errors.First().Message);
            HtmlErrorsDisplay = MvcHtmlString.Create(strError);
        }
        else
        {
            foreach (var ex in model.Errors)
            {
                ViewData.ModelState.AddModelError(string.Empty, ex.Message);
            }
        }
    }

    if (!ViewData.ModelState.IsValid)
    {
        HtmlErrorsDisplay = Html.ValidationSummary("Please correct the following errors and try again:");
    }

    if (HtmlErrorsDisplay == null)
    {
        string errorMessage = TempData.GetMessage(MessageType.Error);
        if (!string.IsNullOrEmpty(errorMessage))
        {
            string strError = string.Format("<b>{0}</b>", errorMessage);
            HtmlErrorsDisplay = MvcHtmlString.Create(strError);
        }
    }
}

@if (HtmlErrorsDisplay != null)
{
<div class="form-messages-panel ui-state-error ui-corner-all"> 
    <span class="message-icon ui-icon ui-icon-alert" style='float:left'></span> 
    @HtmlErrorsDisplay
</div>
}